package com.example.weather.interfaceimpl;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.weather.R;
import com.example.weather.utils.GridViewInterface;

import java.util.ArrayList;
import java.util.Map;

/**
 * Created by hanjun on 2016/6/3.
 */
public class DynamicListItemOperator implements GridViewInterface {

    private Map<String,Object> map;

    public View handle(View convertView, ViewGroup parent, int position,
                       Context context, ArrayList<Map<String, Object>> list,Object object){
        ViewHolder holder;
        map = list.get(position);
        if (convertView == null) {

            LayoutInflater inflater = LayoutInflater.from(context);
            convertView = inflater.inflate(R.layout.select_city,parent, false);
            holder = new ViewHolder();
            holder.mCityTextView = (TextView)convertView.findViewById(R.id.tv_city);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.mCityTextView.setText((String)map.get("city"));
        return convertView;
    }

    public class ViewHolder{
        public TextView mCityTextView;
    }

}
